/**
 * 获取会员账户信息
 */
bangkeapp.service('userinfoService', ["$http", "$q", "url", function($http, $q, url) {
	var browser = {
	    versions:function(){
	        var u = navigator.userAgent, app = navigator.appVersion;
	        return {
	            trident: u.indexOf('Trident') > -1, //IE内核
	            presto: u.indexOf('Presto') > -1, //opera内核
	            webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
	            gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
	            mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
	            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
	            android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
	            iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器
	            iPad: u.indexOf('iPad') > -1, //是否iPad
	            webApp: u.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
	            weixin: u.indexOf('MicroMessenger') > -1, //是否微信 （2015-01-22新增）
	            qq: u.match(/\sQQ/i) == " qq" //是否QQ
	        };
	    }(),
	    language:(navigator.browserLanguage || navigator.language).toLowerCase()
	};
	var member = {};
	
	if (browser.versions.android){
		member = angular.fromJson(android.getUserInfo())[0];
	} else {
		member = {"agentid":"","cardid":"","gragh":"defhead/Flower.png","idcard":"36220419890808001X","isactivated":"","logintype":"01","memberid":"1000000939","memberlevel":"02","memberleveldesc":"高级会员","membername":"姚潘测试","password":"i5YoL5fbmnteeBT/9l4G1A==","reference":"1000000001","tel":"18600273665","verificationcode":"9506","verifystatus":"01","verifystatusname":"审核通过","verifytime":"2017-12-18 09:29:13","verifyuserid":"1000000001"};
		// member = {"agentid":"","cardid":"","email":"5698152@qq.com","gragh":"defhead/Flower.png","idcard":"410402198501165557","isactivated":"","isidcardcheck":"0","logintype":"01","memberid":"1000000106","memberlevel":"01","memberleveldesc":"普通会员","membername":"毛东辉","name":"毛东辉","password":"c0Hs/UeeSc37X4k+GQBjFg==","reference":"1000000001","tel":"18737587375","verificationcode":"1034","verifystatus":"01","verifystatusname":"审核通过","verifytime":"2017-11-27 20:14:13","verifyuserid":"1000000001","yhltel":"18737587375","ylhaccount":"毛东辉"};
		// member = {"agentid":"","cardid":"","gragh":"defhead/Flower.png","idcard":"111111111111111111","isactivated":"","isidcardcheck":"0","logintype":"01","memberid":"1000000001","memberlevel":"01","memberleveldesc":"普通会员","membername":"平台","name":"平台","password":"c0Hs/UeeSc37X4k+GQBjFg==","tel":"13444444444","verifystatus":"01","verifystatusname":"审核通过","verifytime":"2017-11-27 20:13:20","verifyuserid":"1000000001"};
		// member = {"agentid":"","cardid":"","gragh":"defhead/Flower.png","idcard":"41072119670308310X","isactivated":"","isidcardcheck":"0","logintype":"01","memberid":"1000000110","memberlevel":"01","memberleveldesc":"普通会员","membername":"李凤","password":"2/Nt3uc/hwK+V2K6COEnRg==","reference":"1000000017","tel":"13462213196","verificationcode":"3776","verifystatus":"01","verifystatusname":"审核通过","verifytime":"2017-11-27 20:15:07","verifyuserid":"1000000001"};
		// member = {"agentid":"","cardid":"","gragh":"defhead/Flower.png","idcard":"320106198310290811","isactivated":"","logintype":"01","memberid":"1000000937","memberlevel":"03","memberleveldesc":"商户会员","membername":"测试二号","password":"2/Nt3uc/hwK+V2K6COEnRg==","reference":"1000000936","tel":"18515984314","verificationcode":"3538","verifystatus":"01","verifystatusname":"审核通过","verifytime":"2017-11-27 22:16:33","verifyuserid":"1000000001"};
		// member = {"memberid":"1000000936","agentid":"","cardid":"","gragh":"defhead/Flower.png","idcard":"110226198501272116","isactivated":"","logintype":"01","memberlevel":"03","memberleveldesc":"商户会员","membername":"测试","password":"2/Nt3uc/hwK+V2K6COEnRg==","reference":"1000000001","tel":"18510867106","verificationcode":"9441","verifystatus":"01","verifystatusname":"审核通过","verifytime":"2017-11-27 22:11:53","verifyuserid":"1000000001"};
	}
    
	// 获取信息结构
    this.getData = function() { 
    	
	    var data = {};
		data.request = {};
		data.request.body = {};
		data.request.header = {};
		data.request.body.page = "";
		data.request.body.pagesize = "";
		data.request.header.askserialno = "";
		data.request.header.dealcode = "";
		data.request.header.logincomcode = "";
		data.request.header.requesttype = "";
		data.request.header.sendtime = "";
		data.request.header.systemcode = "APP";
		data.request.header.password = member.password;
		data.request.header.verificationcode = member.verificationcode;
		data.request.header.logintype = member.logintype;
		data.request.header.usercode = member.memberid;
	
		return data;
	}
    // 获取信息结构
    this.getNewData = function() { 
    	
	    var data = {};
		data.body = {};
		data.header = {};
		data.body.page = "";
		data.body.pagesize = "";
		data.header.askserialno = "";
		data.header.dealcode = "";
		data.header.logincomcode = "";
		data.headertype = "";
		data.header.sendtime = "";
		data.header.systemcode = "APP";
		data.header.password = member.password;
		data.header.verificationcode = member.verificationcode;
		data.header.logintype = member.logintype;
		data.header.usercode = member.memberid;
	
		return data;
	}
    
    // 获取用户信息
    this.getUser = function(){
    		return member;
    }
    // 获取用户信息
    this.setUser = function(newmember){
	    	if (browser.versions.android){
			android.setUserInfo(angular.fromJson(newmember));
		}
    }
}]);